const regs = {
    email: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
    number: /^\+?[1-9][0-9]*$/,
    password: /^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[\W_]).{8,18}$/,
    version: /^[0-9.]+$/ //版本号
}
const verify = (rule, value, reg, callback) => {
    if (value) {
        if (reg.test(value)) {
            callback();
        } else {
            callback(new Error(rule.message))
        }
    } else {
        callback()
    }
}
const checkEmail = (value) => {
    return regs.email.test(value)
}
const checkPassword = (value) => {
    return regs.password.test(value)
}
const password = (rule, value, callback) => {
    return verify(rule, value, regs.password, callback)
}
const number = (rule, value, callback) => {
    return verify(rule, value, regs.number, callback)
}
const version = (rule, value, callback) => {
    return verify(rule, value, regs.version, callback)
}
export default {
    checkEmail, checkPassword, password, number, version
}